package com.tedu.web.pojo;

/**
 * 所有的web项目在设计响应数据时，都有一个规范，比如说要响应给客户端什么数据，
 * 以什么格式响应，当前项目基于jesonResult响应客户端
 * 基于此对象封装服务端响应到客户段的数据，通常包含三部分类容
 * 1）状态码
 * 2）消息
 * 3）数据
 * */

public class JesonResult {
    /**状态码*/
    private Integer state=1;//1表示ok,0表示Exception
    /**状态信息*/
    private String message;
    /**响应数据，一般为查询结果*/
    private Object data;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public JesonResult(Integer state, String message, Object data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }

    public JesonResult(Integer state, String message) {
        this.state = state;
        this.message = message;
    }

    public JesonResult(String message, Object data) {
        this.message = message;
        this.data = data;
    }

    public JesonResult(Integer state, Object data) {
        this.state = state;
        this.data = data;
    }

    public JesonResult(Integer state) {
        this.state = state;
    }

    public JesonResult(String message) {
        this.message = message;
    }

    public JesonResult(Object data) {
        this.data = data;
    }
    public JesonResult(Throwable e){
        this.state=0;
        this.message=e.getMessage();
    }
    public JesonResult() {

    }

    @Override
    public String toString() {
        return "JesonResult{" +
                "state=" + state +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
